﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;

public class BtnClick : MonoBehaviour {
    Slider slider;
    GameObject allSlide;
    bool loadprocess;
    Image panelImage;
	// Use this for initialization
	void Start () {
        Button btn = this.GetComponent<Button>();
        btn.onClick.AddListener(OnClick);
        slider = GameObject.Find("Slider").GetComponent<Slider>();
        loadprocess = false;

        allSlide = GameObject.Find("Slider");
        //allSlide.SetActive(false);

        panelImage = GameObject.Find("Panel").GetComponent<Image>();
    }
	
	// Update is called once per frame
	void Update () {
        if (loadprocess)
        {
            Invoke("LoadProgress", 0.2f);
            if(slider.value==100)
            {
                loadprocess = false;
            }
        }
        
    }
    private void OnClick()
    {
        allSlide.SetActive(true);
        loadprocess = true;

        Sprite sp = Resources.Load("logo", typeof(Sprite)) as Sprite;
        panelImage.sprite = sp;
    }
    private void LoadProgress()
    {
        slider.value++;
    }
}
